﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;

namespace GUI
{
    public partial class frmDoiMatKhau : Form
    {
        public frmDoiMatKhau()
        {
            InitializeComponent();
        }
        SqlDataReader dr;
        NguoiDungBUS nd = new NguoiDungBUS();
        private void btDoiMK_Click(object sender, EventArgs e)
        {
            dr = nd.DataNguoiDung(frmMain.user);
            dr.Read();
            string a = dr["PassWord"].ToString();
            dr.Close();
            if (a.Trim() == txtMatKhauCu.Text)
            {
                if (txtMatKhauMoi.Text == txtLapLaiMatKhauMoi.Text)
                {
                    nd.updatepaw(txtLapLaiMatKhauMoi.Text, frmMain.user);
                    MessageBox.Show("Doi Thanh Cong", "Thong Bao");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("mat khau ban nhap lai chua dung");
                    txtMatKhauMoi.Text = "";
                    txtMatKhauMoi.Focus();
                }
            }
            else
            {
                MessageBox.Show("mat khau ban nhap chua dung");
                txtMatKhauCu.Text = "";
                txtMatKhauCu.Focus();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
